<!--
*  功能描述：项目关联合同反填页面
 -->
<template>
    <div>
        <div>
            
    <el-tag style="width: 100%; text-align: left; font-size: 20px"
      >项目信息</el-tag
    >
    <h2>项目信息</h2>
      <el-descriptions :model="CustomerData" :column="2" border>
        <el-descriptions-item label="合同关联">
          <el-input v-model="CustomerData.ProjectConId" placeholder="请输入内容" style="width:200px"></el-input>
        </el-descriptions-item> 
        <el-descriptions-item label="项目名称">
          <el-input v-model="CustomerData.ProjectName" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="序号">
          <el-input v-model="CustomerData.ProjectId" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="管理级别">
          <el-input v-model="CustomerData.ProjectLevel" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="建筑类别">
          <el-input v-model="CustomerData.ProjectBuildtype" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="合同额(万元)">
          <el-input v-model="CustomerData.ProjectPrice" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="建设规模">
          <el-input v-model="CustomerData.ProjectScale" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="开始时间">
          <el-input v-model="CustomerData.ProjectStartTime" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="结束时间">
          <el-input v-model="CustomerData.ProjectEndTime" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="电话">
          <el-input v-model="CustomerData.ProjectPhone" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="承接部门">
          <el-input v-model="CustomerData.ProjectDeptId" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
        <el-descriptions-item label="甲方联系人">
          <el-input v-model="CustomerData.ProjectRid" placeholder="请输入内容"></el-input>
        </el-descriptions-item>
      </el-descriptions>
    </div>
    <div>
      <el-dialog
        title="合同关联"
        :visible.sync="dialogVisible"
      >
      <el-form :inline="true" :model="server" class="demo-form-inline">
        <el-form-item label="合同名称">
          <el-input v-model="server.ContractName" placeholder="合同名称"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="onsubmit" icon="el-icon-search" circle ></el-button>
        </el-form-item>
      </el-form>
      <el-table :data="dataxl" style="width: 100%">
        
          <el-table-column prop="ContractNumber" label="序号" width="60px">
          </el-table-column>
          <el-table-column prop="ContractName" label="合同名称">
          </el-table-column>
          <el-table-column prop="OwnerType" label="甲方类型">
          </el-table-column>
          <el-table-column prop="Development" label="建设单位">
          </el-table-column>
          <el-table-column prop="BuildingArea" label="建筑面积(m²)">
          </el-table-column>
          <el-table-column prop="RealyContractPrice" label="实际合同金额(万元)">
          </el-table-column>
          <el-table-column prop="ContractState" label="合同允许状态">
          </el-table-column>
          <el-table-column label="操作" width="100">
              <template slot-scope="scope">
              <!-- <el-button @click="delContract(scope.row.id)" type="text" size="small">删除</el-button> -->
              <el-button type="text" @click="AddCon(scope.row.ProjectId)">选择</el-button>

            </template>
          </el-table-column>

        </el-table>
      </el-dialog>
    </div>
    </div>
</template>
<script>
export default{
    data(){
        return {
            CustomerData: [],
            ProjectId:0,
            dialogVisible:false,
            dataxl:[],
            server: {
        ContractName: "",
      },
        }
    },
    created(){
        this.editCustInfoEdit ();
        this.Show();
        this.onsubmit();
    },
    methods:{
        onsubmit(){
      this.Show();
    },
        handleClick(pid){
        this.ProjectId=pid;
        this.dialogVisible=true;
    },
        editCustInfoEdit () {
            var ProjectId = this.$route.params.ProjectId
      this.$http({
        url: "Operation/FindPro",
        method: "Get",
        params: {
          ProjectId: ProjectId,
        },
      }).then((res) => {
        this.CustomerData = res.data;
      });
        
    },
    AddCon(val){
      this.$http({
        url:"Operation/AddConpro",
        method:"post",
        params:{
          pid:this.ProjectId,
          cid:val,
        }
      }).then(res=>{
        console.log(this.ProjectId)
        console.log(val)
        if(res.data>0){
          this.dialogVisible=false;
          this.$message.success("项目关联成功");
          this.ShowConpro();
        }
      })
    },
    Show(){
            this.$http({
        url: "Operation/SelCon",
        method: "Get",
        params:{
          ContractName:this.server.ContractName
        }
      }).then((res) => {
        this.dataxl = res.data;
        console.log(this.data);
      });
        },
        //时间转换
    dateFormat(fmt, date) {
      let ret = "";
      date = new Date(date);
      const opt = {
        "Y+": date.getFullYear().toString(), // 年
        "m+": (date.getMonth() + 1).toString(), // 月
        "d+": date.getDate().toString(), // 日
        "H+": date.getHours().toString(), // 时
        "M+": date.getMinutes().toString(), // 分
        "S+": date.getSeconds().toString(), // 秒
        // 有其他格式化字符需求可以继续添加，必须转化成字符串
      };
      for (let k in opt) {
        ret = new RegExp("(" + k + ")").exec(fmt);
        if (ret) {
          fmt = fmt.replace(
            ret[1],
            ret[1].length == 1 ? opt[k] : opt[k].padStart(ret[1].length, "0")
          );
        }
      }
      return fmt;
    },
    }
}
</script>